package com.ruoyi.biz.imported;

import com.ruoyi.biz.export.enums.ExportTemplateEnum;
import com.ruoyi.biz.export.executor.AbstractExecutor;
import com.ruoyi.biz.imported.enums.ImportedTemplateEnum;
import com.ruoyi.biz.imported.strategy.ImportedStrategy;
import com.ruoyi.biz.imported.vo.ReqVO;
import com.ruoyi.biz.letter.domain.BizCityLetter;
import com.ruoyi.biz.letter.export.BizCityLetterExport;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author Fei.Cong
 * @date 2024-07-17 14:09
 */
@RestController
@RequestMapping("/letter/import")
public class ImportedController extends BaseController {

    /**
     * 地市信访导入
     *
     * @param file
     * @param updateSupport
     * @return
     * @throws Exception
     */
    @Log(title = "地市信访导入", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('city:letter:import')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport, String importType, String billMonth) throws Exception {

        ImportedStrategy strategy = ImportedTemplateEnum.getTemplateType(importType);
        ReqVO reqVo = ReqVO.builder()
                .updateSupport(updateSupport)
                .billMonth(billMonth)
                .file(file)
                .importTemplateEnum(ImportedTemplateEnum.getType(importType))
                .build();
        return success(strategy.importHandleData(reqVo));

    }

}
